
 
 F u n c t i o n :   l o o p ( o b j e c t ,   f u n c t i o n C a l l b a c k ( k e y ,   v a l u e ) ,   s t r i n g T y p e ) 
 
 
 
 D e s c r i p t i o n :   P e r f o r m s   a   r e c u r s i v e   l o o p   t h a t   s u p p o r t s   t h e   s a m e   c a l l b a c k   s y n t a x   f o r   m u l t i p l e   o b j e c t   t y p e s . 
 
 
 
 R e t u r n s :   R e f e r e n c e d   O b j e c t ,   o r   $ A   o b j e c t   i f   c h a i n e d . 
 
 
 
 N o t e :   W h e n   p a s s i n g   a n   o b j e c t   t o   l o o p ( ) ,   t h e   s t r i n g T y p e   p a r a m e t e r   m u s t   r e f l e c t   t h e   c o r r e c t   t o k e n   f o r   t h a t   o b j e c t   t y p e .   T h e   f u n c t i o n   w i l l   a t t e m p t   t o   g u e s s   i f   o m i t t e d ,   b u t   s e t t i n g   a n   e x p l i c i t   d e c l a r a t i o n   w i l l   a l w a y s   w o r k   b e s t .   T h e   c a l l b a c k   s y n t a x   i s   a l w a y s   a s   f o l l o w s :   f u n c t i o n ( i n d e x O r K e y N a m e ,   r e f e r e n c e d V a l u e O r O b j e c t ) ,   n o   m a t t e r   w h i c h   o b j e c t   t y p e   i s   b e i n g   p r o c e s s e d .   O b j e c t   t y p e   t o k e n s   m u s t   a l w a y s   b e   i n   l o w e r   c a s e . 
 
 
 
 T y p e   T o k e n s 
 
 
 
 " a r r a y " :   W h e n   o b j e c t   m a t c h e s   t y p e   A r r a y 
 
 " m a p " :   W h e n   o b j e c t   m a t c h e s   t y p e   M a p 
 
 " o b j e c t " :   W h e n   o b j e c t   m a t c h e s   t y p e   O b j e c t 
 
 " s t r i n g " :   W h e n   o b j e c t   m a t c h e s   t y p e   S t r i n g 
 
 
 
 E x a m p l e : 
 
 
 
 / /   L o o p   t h r o u g h   a n   a r r a y   s u c h   a s   [ 1 ,   2 ,   3 ] 
 
 $ A . l o o p ( a r r a y O b j e c t ,   f u n c t i o n ( i n d e x N u m b e r ,   o b j e c t )   { 
 
     / /   D o   s o m e t h i n g   w i t h   o b j e c t 
 
 } ,   " a r r a y " ) ; 
 
 
 
 / /   L o o p   t h r o u g h   a n   m a p   s u c h   a s   n e w   M a p ( ) 
 
 $ A . l o o p ( m a p O b j e c t ,   f u n c t i o n ( k e y ,   o b j e c t )   { 
 
     / /   D o   s o m e t h i n g   w i t h   o b j e c t 
 
 } ,   " m a p " ) ; 
 
 
 
 / /   L o o p   t h r o u g h   a n   o b j e c t   s u c h   a s   { k e y :   ' v a l u e ' } 
 
 $ A . l o o p ( o b j e c t O b j e c t ,   f u n c t i o n ( k e y ,   o b j e c t )   { 
 
     / /   D o   s o m e t h i n g   w i t h   o b j e c t 
 
 } ,   " o b j e c t " ) ; 
 
 
 
 / /   L o o p   t h r o u g h   a   s t r i n g   s u c h   a s   " W h a t e v e r " 
 
 $ A . l o o p ( s t r i n g O b j e c t ,   f u n c t i o n ( i n d e x N u m b e r ,   c h a r a c t e r )   { 
 
     / /   D o   s o m e t h i n g   w i t h   c h a r a c t e r 
 
 } ,   " o b j e c t " ) ; 
 
 
 
 / /   O r   t h e   s a m e   u s i n g   c h a i n i n g 
 
 
 
 / /   L o o p   t h r o u g h   a n   a r r a y   s u c h   a s   [ 1 ,   2 ,   3 ] 
 
 v a r   m y C h a i n   =   $ A ( [ d o m E l e m e n t 1 ,   d o m E l e m e n t 2 ] ) . l o o p ( f u n c t i o n ( i n d e x N u m b e r ,   o b j e c t )   { 
 
     / /   D o   s o m e t h i n g   w i t h   o b j e c t 
 
 } ,   " a r r a y " ) ; 
 
 
 
 / /   T o   r e t u r n   t h e   m o d i f i e d   e l e m e n t   w i t h i n   a   c h a i n ,   u s e   t h e   " r e t u r n ( ) "   m e t h o d . 
 
 
 
 v a r   m y E l e m e n t   =   m y C h a i n . r e t u r n ( ) ; 
 
 